package com.hulk.hyena.project.monitor.quartz.service;

import java.util.Date;
import java.util.List;
import java.util.Objects;

import com.hulk.hyena.common.utils.StringUtils;
import com.hulk.hyena.project.monitor.quartz.domain.SysJobLog;
import com.hulk.hyena.project.monitor.quartz.mapper.JobLogMapper;
import com.hulk.hyena.framework.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 定时任务日志 服务实现类
 * </p>
 *
 * @author hulk
 */
@Service
public class JobLogServiceImpl extends BaseServiceImpl<JobLogMapper, SysJobLog> implements IJobLogService {

    @Override
    public List<SysJobLog> selectJobLogList(SysJobLog jobLog) {
        Date beginTime = jobLog.getBeginTime();
        Date endTime = jobLog.getEndTime();
        return query()
                .like(StringUtils.isNotEmpty(jobLog.getJobName()), SysJobLog::getJobName, jobLog.getJobName())
                .like(StringUtils.isNotEmpty(jobLog.getClassName()), SysJobLog::getClassName, jobLog.getClassName())
                .eq(Objects.nonNull(jobLog.getStatus()), SysJobLog::getStatus, jobLog.getStatus())
                .gt(Objects.nonNull(beginTime), SysJobLog::getCreateTime, beginTime)
                .lt(Objects.nonNull(endTime), SysJobLog::getCreateTime, endTime)
                .list();
    }
}
